﻿package app.view.components.sections.expo.max 
{
	import app.model.types.SectionType;
	import app.model.vo.SectionVO;
	import app.view.components.buttons.GlamurBtnBase;
	import app.view.components.header.HeadMarkerBase;
	import app.view.components.sections.LabeledSectionBase;
	import app.view.events.UIEvent;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	/**
	 * 1.1.2 КАРТА ПАВИЛЬОНА
	 * firsoff maxim, snzflash.com, tel: +79222345364, skype: maxim.firsoff
	 */
	public class ExpoPavilionMapMBase extends LabeledSectionBase
	{
		// app.view.components.sections.expo.max.ExpoPavilionMapMBase
		
		public var btn_videoPresent:GlamurBtnBase;
		public var btn_MapRoute:GlamurBtnBase;
		public var sostavExpozit_Btn:GlamurBtnBase;
		
		public var text:TextField;
		
		public function ExpoPavilionMapMBase() 
		{
			super();
		}
		
		override protected function init():void
		{
			super.init();
			
			
			
			text.wordWrap = true;
			text.multiline = true;
		}
		
		private function setEvents():void
		{
			btn_MapRoute.addEventListener(MouseEvent.CLICK, onClickMapRouteBtn);
			sostavExpozit_Btn.addEventListener(MouseEvent.CLICK, onCLickSostavExpo);
			btn_videoPresent.addEventListener(MouseEvent.CLICK, onCLickVideoPresetnBtn);
		}
		
		private function removeEvents():void
		{
			btn_MapRoute.removeEventListener(MouseEvent.CLICK, onClickMapRouteBtn);
			sostavExpozit_Btn.removeEventListener(MouseEvent.CLICK, onCLickSostavExpo);
			btn_videoPresent.removeEventListener(MouseEvent.CLICK, onCLickVideoPresetnBtn);
			
		}
		
		override public function onDestroy():void 
		{
			// чистим что тут есть и вызываем супера
			removeEvents();
			
			btn_MapRoute.destroy();
			sostavExpozit_Btn.destroy();
			btn_videoPresent.destroy();
			
			
			super.onDestroy();
		};
		
		override public function get data():Object { return _data; };
		
		override public function set data(value:Object):void 
		{
			super.data = value;
			
			setParamHead(HeadMarkerBase.BGD_RED);
			
			
			////trace('data!!!',_data.data);
			
			
			
			btn_MapRoute.setLang(_data.lang);
			sostavExpozit_Btn.setLang(_data.lang);
			btn_videoPresent.setLang(_data.lang);
			
			var str:String = '';
			for each(var object:* in _data.data.txt)
			{
				str = String(object.text).substr(1);
			}
			text.htmlText = str;
			
			setEvents();
		};
		
		/**
		 * переход в карту и маршрут
		 * @param	e
		 */
		private function onClickMapRouteBtn(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_EXPO_MAP_AND_ROUTE;
			obj.currentId = id;
			obj.params = null;
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		/**
		 * переход в состав экспозиции
		 * @param	e
		 */
		private function onCLickSostavExpo(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_EXPO_STRUCTURE_EXPOSITIONS;
			obj.currentId = id;
			obj.params = null;
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		/**
		 * переход в видео презентацию
		 * @param	e
		 */
		private function onCLickVideoPresetnBtn(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_EXPO_PAVILION_VIDEO_PRESENT;
			obj.currentId = id;
			obj.params = null;
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		
	}

}